package com.example.frickytest;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.Parcel;

public class myService extends Service {
	private IBinder mBinder = null;
	private Context ctx;

	@Override
	public void onCreate() {
		mBinder = new myBinder();
		ctx = this.getApplicationContext();
	}

	@Override
	public IBinder onBind(Intent intent) {
		Thread.currentThread().setName(
				Thread.currentThread().getName() + "-SRV::onBind");
		return mBinder;
	}

	// -------------------------------------------------------------
	class myBinder extends Binder {
		@Override
		public boolean onTransact(int code, Parcel data, Parcel reply, int flags)
				throws android.os.RemoteException {
			Intent i = new Intent(ctx, myActivity.class);
			i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			ctx.startActivity(i);
			reply.writeString(Thread.currentThread().getName());
			return true;
		}
	}
}